Skip to content

Correct the Secure Boot db enrolment table from measurement - #148

Merged
mastacontrola merged 1 commit into
masterfrom
fix-1267-secure-boot-variable-table
Aug 28, 2026
Merged

mastacontrola merged 1 commit into
masterfrom
fix-1267-secure-boot-variable-table

Conversation

@mastacontrola

Copy link
Copy Markdown
Member

Closes the measurement half of fogproject#1267.

The table in these two pages was mechanism-based reasoning from one measured
cell, and #1267 was opened to check it. I measured it. Two of its claims were
wrong, and the correction changes the advice.

Rig

QEMU 10.2.2, q35,smm=on (SMM matters — it is what protects the varstore from
the guest), edk2-ovmf 20260508, writing through efivarfs from a Linux guest.

Two starting states:

  • OVMF_VARS_4M.qcow2 — no PK → Setup Mode
  • OVMF_VARS_4M.secboot.qcow2 — Microsoft's PK/KEK/db → User Mode, and a PK
    whose private key I do not hold: the real-hardware situation

Every run produces successes and denials in the same boot, so a denial is
firmware policy rather than a broken rig.

What changed in the docs

1. "The write is unauthenticated" → unverified, not unsigned.
Setup Mode skips the signature check. It does not accept a bare certificate: a
raw .esl/.der write to db, KEK or PK is EINVAL even in Setup Mode. The
authenticated-variable wrapper is always required. This is the actual reason a
firmware file picker takes MOK.der (it builds the wrapper) while FOG ships
.auth files (its task cannot).

2. "A running OS needs PK, KEK and db" → the count was never the point.

Platform state db signed by enrolled KEK db signed by unenrolled key KEK signed by enrolled PK KEK signed by KEK db unauthenticated
User Mode, Microsoft's PK EACCES EACCES EACCES EACCES EINVAL
User Mode, our PK/KEK accepted EACCES accepted EACCES EINVAL

On a machine holding a vendor PK you do not control, you cannot write db, KEK
or PK. The route is closed, not "more expensive" — writing all three is not a
workaround. FOG's task works because it runs with the platform in Setup/Custom
Mode, which is the same precondition as the firmware-menu row. And once FOG's
own PK and KEK are enrolled, a later db update is accepted on a KEK-signed
update alone — which is what the .auth files actually buy.

3. db alone presupposes someone else supplies the PK.
FOG's real db.auth written by itself lands (8494 bytes) and survives a reboot,
and the platform stays in Setup Mode with SecureBoot=0. Written together with
an unrelated PK and no KEK at all, the reboot comes up SecureBoot=1 with
FOG's certificate in db — which is exactly the VMware dbDefault.file0 shape,
now confirmed on a second platform.

Also confirmed

FOG's own published PK.auth/KEK.auth/db.auth are well formed: written in
Setup Mode all three land, and the next boot is SetupMode=0 SecureBoot=1.

Still untested, and the callouts still ask for it

Physical firmware menus, PowerShell Set-SecureBootUEFI, and whether changing
these variables trips BitLocker recovery in practice.

🤖 Generated with Claude Code

The table said an OS-side enrolment "needs PK, KEK and db", and that a
Setup Mode write is "unauthenticated". Both were mechanism-based reasoning,
which issue 1267 was opened to check. Measured against edk2-ovmf under QEMU
with SMM, writing through efivarfs in both Setup and User Mode:

- "Unauthenticated" means the signature is not *verified*, not that the
  update is unsigned. A raw .esl/.der write is EINVAL even in Setup Mode --
  the authenticated-variable wrapper is always required. That is the real
  reason a firmware picker takes MOK.der while FOG ships .auth files.
- db alone, with no PK anywhere, lands and survives a reboot -- and leaves
  the platform in Setup Mode with SecureBoot=0. So "db alone" presupposes
  that the firmware or hypervisor supplies the PK.
- In User Mode against a platform holding Microsoft's PK, writes to db, KEK
  and PK were all refused with EACCES. The OS route is not "three variables
  instead of one", it is closed; supplying all three is not a workaround.
  FOG's task works because it runs with the platform in Setup/Custom Mode,
  which is the same precondition as the firmware-menu row.
- Once FOG's own PK and KEK are enrolled, a later db update from the OS is
  accepted on a KEK-signed update alone -- which is what the .auth files buy.

Also confirmed FOG's own published PK/KEK/db.auth are well formed: written in
Setup Mode they land and a reboot comes up SecureBoot=1.

Physical firmware menus, PowerShell Set-SecureBootUEFI and BitLocker/PCR 7
remain untested, and the callouts still ask for those reports.

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant